<template>
	<view class="new-detail">
		<view class="title">
			{{detail.title}}
		</view>
		<view class="info">
			<text class="time">发表时间: {{detail.add_time | formatDate}}</text>
			<text>浏览: {{detail.click}}</text>
		</view>
		<view class="content">
			<rich-text :nodes="detail.content"></rich-text>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				id: 0,
				detail: {}
			}
		},
		methods: {
			async getNewsDetail() {
				const res = await this.$http({
					url: '/getnew/'+this.id
				})
				if(res.statusCode !== 200) return uni.showToast({
					title: '获取数据错误'
				})
				this.detail = res.data.message[0]
				console.log(this.detail)
			}
		},
		onLoad(option) {
			this.id = option.id
			this.getNewsDetail()
			console.log(this.id)
		}
	}
</script>

<style lang="scss">
	.new-detail {
		margin: 0 10rpx;
		font-size: 32rpx;
	}
	.title {
		text-align: center;
		font-size: 32rpx;
	}
	.info {
		font-size: 26rpx;
		color: red;
		display: flex;
		justify-content: space-between;
	}
</style>
